{include file="public:header"}
<!--编辑菜单-->
<form id="info_form" action="{:url('editDo')}" method="post">
	<div class="pad_lr_10">
		<div class="col_tab">
			<ul class="J_tabs tab_but cu_li">
				<li class="current">编辑菜单</li>
			</ul>
			<div class="J_panes">
				<div class="content_list pad_10">
					<table width="100%" class="table_form">
						<tr>
							<th width="120">上级菜单 :</th>
							<td>
								<select class="J_cate_select mr10" data-pid="0" data-uri="{:url('ajaxGetchilds')}" data-selected="{$info.spid}"></select>
								<input type="hidden" name="pid" id="J_cate_id" />
								<span>默认为一级菜单</span>
							</td>
						</tr>
						<tr>
							<th>菜单事件 :</th>
							<td>
								<select name="type" id="type" onchange="hideUrl(this);">
									{volist name="typeArr" id="vo"}
									<option value="{$key}" {if condition="$key eq $info->getData('type')"}selected{/if}>{$vo}</option>
									{/volist}
								</select>
								<span>含有子菜单的一级菜单 可选择无</span>
							</td>
						</tr>
						<tr>
							<th>菜单名称 :</th>
							<td>
								<input type="text" name="name" value="{$info.name}" id="name" placeholder="一级最多4个字符 二级最多7个字符" class="input-text" size="30">
								（可创建最多 3 个一级菜单，每个一级菜单下可创建最多 5 个二级菜单）
							</td>
						</tr>
						<tr id="tr_url" {if condition="$info->getData('type') neq 'view'"}style="display:none;"{/if}>
							<th>链接地址 :</th>
							<td>
								<input type="text" name="url" value="{$info.url}" id="url" class="input-text" size="30">
							</td>
						</tr>
						<tr>
							<th>菜单别名 :</th>
							<td>
								<input type="text" name="alias" id="alias" value="{$info.alias}" class="input-text" size="20"><span>事件类型为推送事件时请设置菜单别名</span>
							</td>
						</tr>

					</table>
				</div>
			</div>
			<input type="hidden" name="id" value="{$info.id}">
			<div class="mt10">
				<input value="提交" id="dosubmit" name="" class="btn btn_submit" style="margin:0 10px 0 100px;" type="submit">
				<input type="button" class="btn" value="返回" onclick="location.href='{:url("index")}'">
			</div>
		</div>
	</div>
</form>
{include file="public:footer"}
<script>
	$(function(){
		$.formValidator.initConfig({formid:"info_form",autotip:true});
		$("#name").formValidator({onshow:'请填写名称',onfocus:'请填写名称'}).inputValidator({min:1,onerror:'请填写名称'}).defaultPassed();
		$("#alias").formValidator({onshow:'请填写菜单别名',onfocus:'请填写菜单别名',empty:true,onempty:''}).regexValidator({regexp:'username',datatype:'enum',onerror:'别名只能为数字、字母、或下划线组成'}).defaultPassed();
		$('.J_cate_select').cate_select({level:1});
		$('#info_form').ajaxForm({success:complate,dataType:'json'});
		function complate(result){
			if(result.status == 1){
				$.yingloujie.tip({content:result.msg, icon:'success'});
				setTimeout(function(){window.location.reload()},3000);
			} else {
				$.yingloujie.tip({content:result.msg, icon:'error'});
			}
		}


	});
	function hideUrl(o){
		if(o.value == 'view'){
			$("#tr_url").show();
		}else{
			$("#tr_url").hide();
		}
	}
</script>
